﻿using System;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using BestCode.Creds.Entities;
using BestCode.Creds.UI.Common;
using BestCode.Creds.UI.ViewModel;

namespace BestCode.Creds.UI
{
    /// <summary>
    /// Interaction logic for VwTemplate.xaml
    /// </summary>
    public partial class VwTemplate : UserControl
    {
        private readonly VmTemplate viewModel;
        public event EventHandler OnTemplateSelected;
        
        public VwTemplate()
        {
            InitializeComponent();
            if (!(bool)(DesignerProperties.IsInDesignModeProperty.GetMetadata(typeof(DependencyObject)).DefaultValue))
            {
                viewModel = new VmTemplate();
                this.DataContext = viewModel;
            }
            
        }

        private void btnChangeLayout_OnClick(object sender, RoutedEventArgs e)
        {
            if (OnTemplateSelected != null)
            {
                var obj = ((FrameworkElement)sender).DataContext as Template;
                OnTemplateSelected(obj, EventArgs.Empty);
            }

            /*VwEditFoto editwindow = new VwEditFoto(obj);
            editwindow.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            editwindow.ShowDialog();*/
        }

        
       
    }
}
